<template>
  <Select placeholder="请选择线路" :value="value" @on-change="change" filterable clearable :loading="searchLoading">
    <Option v-for="(option, index) in routeOptions" :value="option.value" :key="`route-select-option-${option.value}`" :label="option.label">
      {{option.label}}
    </Option>
    <ul v-if="routeOptions.length <= 0" class="ivu-select-not-found"><li>暂无数据</li></ul>
  </Select>
</template>

<script>
  import {post}  from '@/util/request'

  export default {
    mounted(){
      post('/atten/route/list').then(res => {
        if (res.data.success){
          this.routeOptions = res.data.data.map(v => {
            return {
              label:v.name,
              value:v.id
            };
          });
        }
      });
    },
    props: ["value"],
    data() {
      return {
        routeOptions: [],
        searchLoading: false
      }
    },
    watch: {
    },
    methods:{
      change(v){
        this.$emit("input", v);
        this.$emit("on-change", v);
      }
    }
  }
</script>
